import Vue from 'vue';
import Router from 'vue-router';
import Login from '@/components/Login';
import Register from '@/components/Register';
import Success from '@/components/Success';
import Test from "@/page/Test";
import TheLayout from "@/views/menu/TheLayout";
import EmployerManager from "@/views/admin/EmployerSys/EmployerManager";
import AdminFirstPage from "@/views/admin/AdminFirstPage";

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/success',
      name: 'Success',
      component: Success
    },
    {
      path: '/test',
      name: 'Test',
      component: Test
    },
    {
      path: '/theLayout',
      name: '管理',
      component: TheLayout,
      menu: true,              //菜单目录要添加此值，login等非菜单目录不需要
      children: [              //一级菜单，children[0]即是链接，要指明名字、图标、组件
        {
          path: '/adminFirstPage',
          name: '首页',
          component: AdminFirstPage,
          meta: {
            role: 'yes',
            requireAuth: true
          },
        },
        {
          path: '/employerManager',
          name: '店长管理',
          component: EmployerManager,
          meta: {

          }
        }
      ]
    }
  ]
})
